home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2747 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: [Q] Porting to ANSI
  5. Date: 23 Jan 1996 13:03:30 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4e37ti$6h9@umbc9.umbc.edu>
  8. References: <DLLu9E.91M@news.zippo.com>
  9. NNTP-Posting-Host: umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. John Muller  <john> wrote:
  13. |> We are attempting to port existing code to ANSI C.  However, we have
  14. |> many instances of something like this:
  15. |> 
  16. |> typedef struct {
  17. |>     :
  18. |>     int    len;
  19. |>     char    data[0];
  20. |> }
  21. |> 
  22. |> Any suggestions for porting this over to ANSI?
  23.  
  24. You have neglected to explain how this is actually being used, i.e. why it
  25. is even necessary to do such a construct. If you are doing what I think you
  26. are doing then using tricks with malloc() and more or less lying to the
  27. compiler you hope to make 'data' dynamic, yet contiguous with the rest of
  28. the structure. Unsurprisingly this is known as the struct hack and is
  29. well discussed in the FAQ. The response is long so please look it up yourself
  30. in question 2.6. Copies are freely available electronically via FTP at
  31. rtfm.mit.edu.
  32. -- 
  33. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  34.  
  35. Jonas J. Schlein  (schlein@gl.umbc.edu)
  36.